package com.learn.admin.modules.sys.security;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 表单验证过滤类
 */
public class CustomFormAuthenticationFilter extends FormAuthenticationFilter {

    @Override
    protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) {
        String username = getUsername(request);
        String password = getPassword(request);
        boolean rememberMe = isRememberMe(request);
        // TODO 获取验证码、访问地址
        String host = "127.0.0.1";
        String captcha = "6666";
        boolean mobile = false;
        return new CustomUsernamePasswordToken(username, password.toCharArray(), rememberMe, host, captcha, mobile);
    }
}
